<?php
	
	require_once('inc/fen_fns.php');
	
	sec_session_start();
	
	$form_values = $_POST;

	if(login_check($mysqli, '>', '10') == true) {
	
		foreach($form_values as $x=>$x_value)
		{
		
			$delete = substr($x_value,2);
		
			$query = $_DB->Query("select status from fen_publication_app WHERE `fen_publication_app`.`publication_id` = '".$delete."'");
			$status = $_DB->GetResultValue($query, "0", "status");
		
			$query = $_DB->Query("select tesvik from fen_publications WHERE `fen_publications`.`id` = '".$delete."'");
			$tesvik = $_DB->GetResultValue($query, "0", "tesvik");
		
			if ($tesvik == '0' || ($tesvik == '1' && $status == '2')) {
				$query = $_DB->Query("DELETE FROM `buzeb`.`fen_publications` WHERE `fen_publications`.`member_id` = '".$_SESSION['user_id']."' and `fen_publications`.`id` = '$delete'");
				$query = $_DB->Query("DELETE FROM `buzeb`.`fen_publication_app` WHERE `fen_publication_app`.`member_id` = '".$_SESSION['user_id']."' and `fen_publication_app`.`publication_id` = '$delete'");
			} 
		}
	
	} else {
		header('Location: ./index.php?error=2');
	}
	

	
